/*
 * Generated file. 
 * 
 * Main.java
 */
package xsp;

import com.ibm.xsp.page.compiled.AbstractCompiledPage;
import com.ibm.xsp.page.compiled.AbstractCompiledPageDispatcher;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import com.ibm.xsp.page.compiled.NoSuchComponentException;
import com.ibm.xsp.page.compiled.PageExpressionEvaluator;
import java.lang.String;
import javax.faces.el.MethodBinding;
import com.ibm.xsp.component.FacesPageProvider;
import java.util.Map;
import java.lang.Object;
import com.ibm.xsp.component.UIViewRootEx2;

@SuppressWarnings("all")
public class Main extends AbstractCompiledPageDispatcher{
    
    public Main() {
        super("8.5.1"); // version of xp:view viewState
    }

    protected AbstractCompiledPage createPage(int pageIndex) {
        return new MainPage();
    }
    
    public static class MainPage extends AbstractCompiledPage {
        
        private static final ComponentInfo[] s_infos = new ComponentInfo[]{
            ComponentInfo.EMPTY_NORMAL, // 0 view
        };
        
        public MainPage() {
            super(0, s_infos );
        }
        
        public int getComponentForId(String id) throws NoSuchComponentException { 
            return -1;
        }
        
        public UIComponent createComponent(int id, FacesContext context,
                UIComponent parent, PageExpressionEvaluator evaluator)
                throws NoSuchComponentException { 
            switch (id) {
            case 0:
                return createView(context, parent, evaluator);
            }
            throw new NoSuchComponentException(id);
        }
        
        protected void initIncluderAsRoot(FacesContext context,
                PageExpressionEvaluator evaluator, UIComponent root) {
            String sourceId = "/xp:view[1]/xp:this.afterPageLoad[1]/text()";
            MethodBinding afterPageLoad = evaluator.createMethodBinding(root,
                    "#{javascript:\n\t\t\tvar uAgent = context.getUserAgent().getUserAgent();\n\t\t\tif((uAgent.match(\"iPhone\") !== null || param.platform==\"iphone\") ||\n\t\t\t   (uAgent.match(\"Android\") !== null || param.platform==\"android\") ||\n\t\t\t    uAgent.match(\"iPad\") !== null){\n\t\t\t\tcontext.redirectToPage(\"/mobile.xsp\", true);\n\t\t\t}else{\n\t\t\t\tcontext.redirectToPage(\"/allDocuments.xsp\", true);\t\n\t\t\t}\n\t\t}",
                    null,null, sourceId);
            FacesPageProvider asPageProvider = root instanceof FacesPageProvider ?
                    (FacesPageProvider) root : null;
            if( null != asPageProvider ){
                asPageProvider.setAfterPageLoad(afterPageLoad);
            }
            root.setRendered(false);
            Map<String,Object> attrs = getAttributes(root);
            attrs.put("viewState", "nostate");
        }

        private UIComponent createView(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIViewRootEx2 result = new UIViewRootEx2();
            initViewRoot(result);
            String sourceId = "/xp:view[1]/xp:this.afterPageLoad[1]/text()";
            MethodBinding afterPageLoad = evaluator.createMethodBinding(result,
                    "#{javascript:\n\t\t\tvar uAgent = context.getUserAgent().getUserAgent();\n\t\t\tif((uAgent.match(\"iPhone\") !== null || param.platform==\"iphone\") ||\n\t\t\t   (uAgent.match(\"Android\") !== null || param.platform==\"android\") ||\n\t\t\t    uAgent.match(\"iPad\") !== null){\n\t\t\t\tcontext.redirectToPage(\"/mobile.xsp\", true);\n\t\t\t}else{\n\t\t\t\tcontext.redirectToPage(\"/allDocuments.xsp\", true);\t\n\t\t\t}\n\t\t}",
                    null,null, sourceId);
            result.setAfterPageLoad(afterPageLoad);
            result.setRendered(false);
            result.setViewState("nostate");
            return result;
        }

    }
}
